package order.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import order.dao.OrderDAO;
import order.model.OrderVo;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.ModelDriven;

@SuppressWarnings("unused")
public class ViewAction implements Action,Preparable,ModelDriven{
	OrderDAO orderDAO = OrderDAO.getInstance();
	OrderVo orderVo;
	
	private List<OrderVo> list = new ArrayList<OrderVo>();
	private int currentPage;
	private int statuss; 
	
	
	public String execute() throws Exception {
		list = orderDAO.orderSelectOne(orderVo.getOrderNo());
		orderVo = list.get(0);
		return SUCCESS;
	}	
	public String delete() throws Exception{
		orderDAO.orderDelete(orderVo.getItemNo());
		return SUCCESS;
	}
	
	public String statusUpdate() throws Exception{
		Map map = new HashMap();
		System.out.println(statuss);
		map.put("orderNo",orderVo.getOrderNo());
		map.put("status", statuss);
		orderDAO.orderStatesUpdate(map);
		System.out.println(orderVo.toString());
		return SUCCESS;
	}
	
	public OrderVo getOrderVo() {
		return orderVo;
	}

	public void setOrderVo(OrderVo orderVo) {
		this.orderVo = orderVo;
	}

	public List<OrderVo> getList() {
		return list;
	}
	public void setList(List<OrderVo> list) {
		this.list = list;
	}
	
	public int getStatuss() {
		return statuss;
	}
	public void setStatuss(int statuss) {
		this.statuss = statuss;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public void prepare() throws Exception {
		orderVo = new OrderVo();
	}
	public Object getModel() {
		return orderVo;
	}
}
